package Test;

import java.util.Scanner;

public class 将字符串转换成整数 {
    public static void main(String[] args) {
        String regex = "[1-9]\\d{0,9}";
        Scanner sc = new Scanner(System.in);
        int number = 0;
        while (true) {
            String str = sc.nextLine();
            boolean matches = str.matches(regex);
            if (matches) {
                for (int i=0;i<str.length();i++) {
                    int j = str.charAt(i) - '0';
                    number = number * 10 + j;
                }
                break;
            }
            System.out.println("输入的字符串不符合要求");
        }
        System.out.println(number);
    }
}
